package com.zmc.admin.infrastructure.service.impl;

import com.zmc.admin.infrastructure.dao.SysRoleMenuDao;
import com.zmc.common.utils.PageUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zmc.common.utils.Query;

import com.zmc.admin.infrastructure.entity.SysRoleMenuEntity;
import com.zmc.admin.infrastructure.service.SysRoleMenuService;
import org.springframework.transaction.annotation.Transactional;


/**
 * @author zmc
 */
@Service("sysRoleMenuService")
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuDao, SysRoleMenuEntity> implements SysRoleMenuService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SysRoleMenuEntity> page = this.page(
                new Query<SysRoleMenuEntity>().getPage(params),
                new QueryWrapper<SysRoleMenuEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public int checkMenuExistRole(Long menuId) {
        return baseMapper.checkMenuExistRole(menuId);
    }

    @Override
    @Transactional
    public void insertBatch(List<SysRoleMenuEntity> list) {
        baseMapper.insertBatch(list);
    }

    @Override
    @Transactional
    public void deleteByRoleId(Long roleId) {
        baseMapper.deleteByRoleId(roleId);
    }

    @Override
    @Transactional
    public void deleteByRoleIds(List<Long> roleIds) {
        baseMapper.deleteByRoleIds(roleIds);
    }

}